package collection;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;

public class SortString {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("area");
        list.add("Mnn");
        list.add("Kobe");
        list.add("tom");
        list.add("tero");
        list.add("chen");
        System.out.println(list);
        Collections.sort(list);
        System.out.println(list);

        List<String> list1 = new ArrayList<>();
        list1.add("李好");
        list1.add("赵黄丑丑");
        list1.add("李好很优秀");
        System.out.println("list1:"+list1);
        Collections.sort(list1, new Comparator<String>() {
            @Override
            public int compare(String o1, String o2) {
                return o2.length()-o1.length();
            }
        });
        System.out.println("list1:"+list1);
        Collections.sort(list1,(o1,o2)->o1.length()-o2.length());
        System.out.println("list1:"+list1);
       // Collections.sort(list1, Comparator.comparingInt(String::length));
    }

}
